<!DOCTYPE HTML>
<html>
<head>
    <title>安置帮教救助信息</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <script src="/webjars/miniui/boot.js" type="text/javascript"></script>
    <link href="/static/css/resource.css" rel="stylesheet" type="text/css" />
    <link href="/static/css/default.css" rel="stylesheet" type="text/css" />
    <script src="/static/js/common/common.js" type="text/javascript"></script>
</head>
<style>
    .delBtn {
        border:1px solid #ff2120;
        border-radius:10px;
        font-size:8px;
        line-height:20px;
        font-weight:bold;
        color:#ff4634;
    }
    .editBtn {
        border:1px solid #018d00;
        border-radius:10px;
        font-size:8px;
        line-height:20px;
        font-weight:bold;
        color:#00a60a;
    }
</style>
<body>
<div class="mini-fit">
    <#--罪犯编号-->
    <input id="priNum" name="priNum" class="mini-hidden" value="${priNum}" />
    <div style="height:100%;width: 100%;overflow-x: auto;overflow-y: auto;padding: 10px;">
        <div id="editform" class="form" style="padding:10px;">
            <span style="font-size: 15px">${pname!''}&emsp;</span>/<span style="font-size: 15px">${sex!''}</span>
        </div>
        <div id="editform2" class="form" style="padding:10px;">
            <table class="form-table" width="100%">
                <tr style="line-height: 30px;">
                    <td width="40%"><span style="color: #8B8B8B">身份证号:&emsp;</span>${idnum!''}
                    </td>
                    <td width="40%"><span style="color: #8B8B8B">出生日期:&emsp;</span>${age!''}
                    </td>
                </tr>
                <tr style="line-height: 30px;">
                    <td><span style="color: #8B8B8B">户籍地址:&emsp;</span>${hjdz!''}
                    </td>
                    <td><span style="color: #8B8B8B">居住地址:&emsp;</span>${jzdz!'无'}
                    </td>
                </tr>
            </table>
        </div>
        <div id="editform3" class="form" style="padding:10px;">
            <span style="font-size: 18px">救助信息&emsp;&emsp;&emsp;</span> <a class="mini-button mini-button-primary"
                                                                           onclick="addJzInfoData('${priNum!''}')">新增</a>
        </div>
        <div>
            <div id="datagrid1" class="mini-datagrid" style="width: 100%;" ajaxType="get" alwaysShowEmptyText="true"
                 autoload="true" showEmptyText="true" emptyText="暂无数据" multiSelect="true" showPager="false"
                 url="/azbj/azbjgl/bjgzgl/view/getJzInfoList?priNum=${priNum!''}">
                <div property="columns">
                    <div type="indexcolumn" align="center" headerAlign="center" width="20%">序列</div>
                    <div name="jztime" field="jztime" width="25%" align="center" headerAlign="center" allowSort="false">救助时间
                    </div>
                    <div name="shjz" field="shjz" width="25%" align="center" headerAlign="center" allowSort="false">救助类型
                    </div>
                    <div name="action" width="30%" align="center" headerAlign="center" renderer="onActionRenderer" allowSort="false">操作
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>

<script type="text/javascript">
    mini.parse();
    var ftab = 1;
    var priNumObj = mini.get("priNum");
    var grid = mini.get("datagrid1");
    var width;
    if(${localCode} == "140000") {
        width = "100%";
    } else {
        width = "70%";
    }
    //渲染列中按钮
    function onActionRenderer(e) {
        var s = '';
        s += '&nbsp;<a class="mini-button mini-button-primary"  onclick="editJzInfoData()"  >&nbsp;&nbsp;编辑&nbsp;&nbsp;</a>&nbsp';
        s += '&nbsp;<a class="mini-button mini-button-danger"   onclick="delJzInfoData()"   >&nbsp;&nbsp;删除&nbsp;&nbsp;</a>&nbsp';
        s += '&nbsp;<a class="mini-button mini-button-info"   onclick="viewJzInfoData()"   >&nbsp;&nbsp;查看&nbsp;&nbsp;</a>&nbsp';
        return s;
    }

    function editJzInfoData() {
        var row = grid.getSelected();
        mini.open({
            targetWindow: window.parent,
            url: "/azbj/azbjgl/bjgzgl/view/toEditSuccourTab?jzId=" + row.id + "&priNum=" + priNumObj.getValue(),
            title: "编辑-救助",
            width: width,
            height: "80%",
            allowDrag: true,
            allowResize: false,
            showCloseButton: true,
            onload: function () {
            },
            ondestroy: function (action) {
                grid.reload();
            }
        });
    }

    function viewJzInfoData() {
        var row = grid.getSelected();
        mini.open({
            targetWindow: window.parent,
            url: "/azbj/azbjgl/bjgzgl/view/toViewSuccourTab?jzId=" + row.id + "&priNum=" + priNumObj.getValue(),
            title: "查看-救助",
            width: width,
            height: "80%",
            allowDrag: true,
            allowResize: false,
            showCloseButton: true,
            onload: function () {
            },
            ondestroy: function (action) {
                grid.reload();
            }
        });
    }

    function delJzInfoData(e) {
        var row = grid.getSelected();
        $.ajax({
            url: "/azbj/azbjgl/azgzgl/view/delJzInfoAction?jzId=" + row.id + "&priNum=" + priNumObj.getValue(),
            type: "post",
            data: {delId: e},
            success: function (result) {
                if (result.code == 1) {
                    mini.alert("删除成功");
                    grid.reload();
                }else if (result.code == 5599) {
                    mini.alert(result.message);
                } else {
                    mini.alert("删除失败");
                }
            }
        });
    }

    //添加救助信息
    function addJzInfoData(PriNum) {
        mini.open({
            targetWindow: window.parent,
            url: "/azbj/azbjgl/bjgzgl/view/toEditSuccourTab?priNum=" + PriNum,
            title: "新增-救助信息",
            width: width,
            height: "80%",
            allowDrag: true,
            allowResize: false,
            showCloseButton: true,
            onload: function () {
            },
            ondestroy: function (action) {
                if(action == "close"){
                    // 点击取消/×号
                    var iframe = this.getIFrameEl();
                    // 获取选中、编辑的结果
                    var data = iframe.contentWindow.GetData();
                    var taskId = data.taskId;
                    var priNum = data.priNum;
                    var id = data.id
                    $.ajax({
                        url: "/upload/downloadAppendixFile/deleteById?1=1&id=" + id + "&priNum=" + priNum + "&taskId=" + taskId[0],
                        type: "get",
                        success: function(success){
                        }
                    });
                    $.ajax({
                        url: "/upload/downloadAppendixFile/deleteById?1=1&id=" + id + "&priNum=" + priNum + "&taskId=" + taskId[1],
                        type: "get",
                        success: function(success){
                        }
                    });
                    $.ajax({
                        url: "/upload/downloadAppendixFile/deleteById?1=1&id=" + id + "&priNum=" + priNum + "&taskId=" + taskId[2],
                        type: "get",
                        success: function(success){
                        }
                    });
                    $.ajax({
                        url: "/upload/downloadAppendixFile/deleteById?1=1&id=" + id + "&priNum=" + priNum + "&taskId=" + taskId[3],
                        type: "get",
                        success: function(success){
                        }
                    });
                    $.ajax({
                        url: "/upload/downloadAppendixFile/deleteById?1=1&id=" + id + "&priNum=" + priNum + "&taskId=" + taskId[4],
                        type: "get",
                        success: function(success){
                        }
                    });
                    $.ajax({
                        url: "/upload/downloadAppendixFile/deleteById?1=1&id=" + id + "&priNum=" + priNum + "&taskId=" + taskId[5],
                        type: "get",
                        success: function(success){
                        }
                    });
                }
                grid.reload();
            }
        });
    }
</script>
</body>
</html>